home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-04-15 | 42.2 KB | 1,390 lines |
- Newsgroups: comp.sources.unix
- From: Christophe.Wolfhugel@univ-lyon1.fr (Chris Wolfhugel)
- Subject: v26i161: tulp-3.0.3 - a listserv-like mailing list manager, V3.0.3, Part02/02
- Sender: unix-sources-moderator@vix.com
- Approved: paul@vix.com
-
- Submitted-By: Christophe.Wolfhugel@univ-lyon1.fr (Chris Wolfhugel)
- Posting-Number: Volume 26, Issue 161
- Archive-Name: tulp-3.0.3/part02
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 2)."
- # Contents: LICENCE l.c lc.c
- # Wrapped by vixie@gw.home.vix.com on Thu Apr 15 18:34:03 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'LICENCE' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'LICENCE'\"
- else
- echo shar: Extracting \"'LICENCE'\" \(12488 characters\)
- sed "s/^X//" >'LICENCE' <<'END_OF_FILE'
- X
- X GNU GENERAL PUBLIC LICENSE
- X Version 1, February 1989
- X
- X Copyright (C) 1989 Free Software Foundation, Inc.
- X 675 Mass Ave, Cambridge, MA 02139, USA
- X Everyone is permitted to copy and distribute verbatim copies
- X of this license document, but changing it is not allowed.
- X
- X Preamble
- X
- X The license agreements of most software companies try to keep users
- at the mercy of those companies. By contrast, our General Public
- License is intended to guarantee your freedom to share and change free
- software--to make sure the software is free for all its users. The
- General Public License applies to the Free Software Foundation's
- software and to any other program whose authors commit to using it.
- You can use it for your programs, too.
- X
- X When we speak of free software, we are referring to freedom, not
- price. Specifically, the General Public License is designed to make
- sure that you have the freedom to give away or sell copies of free
- software, that you receive source code or can get it if you want it,
- that you can change the software or use pieces of it in new free
- programs; and that you know you can do these things.
- X
- X To protect your rights, we need to make restrictions that forbid
- anyone to deny you these rights or to ask you to surrender the rights.
- These restrictions translate to certain responsibilities for you if you
- distribute copies of the software, or if you modify it.
- X
- X For example, if you distribute copies of a such a program, whether
- gratis or for a fee, you must give the recipients all the rights that
- you have. You must make sure that they, too, receive or can get the
- source code. And you must tell them their rights.
- X
- X We protect your rights with two steps: (1) copyright the software, and
- X(2) offer you this license which gives you legal permission to copy,
- distribute and/or modify the software.
- X
- X Also, for each author's protection and ours, we want to make certain
- that everyone understands that there is no warranty for this free
- software. If the software is modified by someone else and passed on, we
- want its recipients to know that what they have is not the original, so
- that any problems introduced by others will not reflect on the original
- authors' reputations.
- X
- X The precise terms and conditions for copying, distribution and
- modification follow.
- X
- X GNU GENERAL PUBLIC LICENSE
- X TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- X
- X 0. This License Agreement applies to any program or other work which
- contains a notice placed by the copyright holder saying it may be
- distributed under the terms of this General Public License. The
- X"Program", below, refers to any such program or work, and a "work based
- on the Program" means either the Program or any work containing the
- Program or a portion of it, either verbatim or with modifications. Each
- licensee is addressed as "you".
- X
- X 1. You may copy and distribute verbatim copies of the Program's source
- code as you receive it, in any medium, provided that you conspicuously and
- appropriately publish on each copy an appropriate copyright notice and
- disclaimer of warranty; keep intact all the notices that refer to this
- General Public License and to the absence of any warranty; and give any
- other recipients of the Program a copy of this General Public License
- along with the Program. You may charge a fee for the physical act of
- transferring a copy.
- X
- X 2. You may modify your copy or copies of the Program or any portion of
- it, and copy and distribute such modifications under the terms of Paragraph
- X1 above, provided that you also do the following:
- X
- X a) cause the modified files to carry prominent notices stating that
- X you changed the files and the date of any change; and
- X
- X b) cause the whole of any work that you distribute or publish, that
- X in whole or in part contains the Program or any part thereof, either
- X with or without modifications, to be licensed at no charge to all
- X third parties under the terms of this General Public License (except
- X that you may choose to grant warranty protection to some or all
- X third parties, at your option).
- X
- X c) If the modified program normally reads commands interactively when
- X run, you must cause it, when started running for such interactive use
- X in the simplest and most usual way, to print or display an
- X announcement including an appropriate copyright notice and a notice
- X that there is no warranty (or else, saying that you provide a
- X warranty) and that users may redistribute the program under these
- X conditions, and telling the user how to view a copy of this General
- X Public License.
- X
- X d) You may charge a fee for the physical act of transferring a
- X copy, and you may at your option offer warranty protection in
- X exchange for a fee.
- X
- Mere aggregation of another independent work with the Program (or its
- derivative) on a volume of a storage or distribution medium does not bring
- the other work under the scope of these terms.
- X
- X 3. You may copy and distribute the Program (or a portion or derivative of
- it, under Paragraph 2) in object code or executable form under the terms of
- Paragraphs 1 and 2 above provided that you also do one of the following:
- X
- X a) accompany it with the complete corresponding machine-readable
- X source code, which must be distributed under the terms of
- X Paragraphs 1 and 2 above; or,
- X
- X b) accompany it with a written offer, valid for at least three
- X years, to give any third party free (except for a nominal charge
- X for the cost of distribution) a complete machine-readable copy of the
- X corresponding source code, to be distributed under the terms of
- X Paragraphs 1 and 2 above; or,
- X
- X c) accompany it with the information you received as to where the
- X corresponding source code may be obtained. (This alternative is
- X allowed only for noncommercial distribution and only if you
- X received the program in object code or executable form alone.)
- X
- Source code for a work means the preferred form of the work for making
- modifications to it. For an executable file, complete source code means
- all the source code for all modules it contains; but, as a special
- exception, it need not include source code for modules which are standard
- libraries that accompany the operating system on which the executable
- file runs, or for standard header files or definitions files that
- accompany that operating system.
- X
- X 4. You may not copy, modify, sublicense, distribute or transfer the
- Program except as expressly provided under this General Public License.
- Any attempt otherwise to copy, modify, sublicense, distribute or transfer
- the Program is void, and will automatically terminate your rights to use
- the Program under this License. However, parties who have received
- copies, or rights to use copies, from you under this General Public
- License will not have their licenses terminated so long as such parties
- remain in full compliance.
- X
- X 5. By copying, distributing or modifying the Program (or any work based
- on the Program) you indicate your acceptance of this license to do so,
- and all its terms and conditions.
- X
- X 6. Each time you redistribute the Program (or any work based on the
- Program), the recipient automatically receives a license from the original
- licensor to copy, distribute or modify the Program subject to these
- terms and conditions. You may not impose any further restrictions on the
- recipients' exercise of the rights granted herein.
- X
- X 7. The Free Software Foundation may publish revised and/or new versions
- of the General Public License from time to time. Such new versions will
- be similar in spirit to the present version, but may differ in detail to
- address new problems or concerns.
- X
- XEach version is given a distinguishing version number. If the Program
- specifies a version number of the license which applies to it and "any
- later version", you have the option of following the terms and conditions
- either of that version or of any later version published by the Free
- Software Foundation. If the Program does not specify a version number of
- the license, you may choose any version ever published by the Free Software
- XFoundation.
- X
- X 8. If you wish to incorporate parts of the Program into other free
- programs whose distribution conditions are different, write to the author
- to ask for permission. For software which is copyrighted by the Free
- Software Foundation, write to the Free Software Foundation; we sometimes
- make exceptions for this. Our decision will be guided by the two goals
- of preserving the free status of all derivatives of our free software and
- of promoting the sharing and reuse of software generally.
- X
- X NO WARRANTY
- X
- X 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
- XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
- PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
- OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
- TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
- PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
- REPAIR OR CORRECTION.
- X
- X 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
- REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
- INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
- OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
- TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
- YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
- PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGES.
- X
- X END OF TERMS AND CONDITIONS
- X
- X Appendix: How to Apply These Terms to Your New Programs
- X
- X If you develop a new program, and you want it to be of the greatest
- possible use to humanity, the best way to achieve this is to make it
- free software which everyone can redistribute and change under these
- terms.
- X
- X To do so, attach the following notices to the program. It is safest to
- attach them to the start of each source file to most effectively convey
- the exclusion of warranty; and each file should have at least the
- X"copyright" line and a pointer to where the full notice is found.
- X
- X <one line to give the program's name and a brief idea of what it does.>
- X Copyright (C) 19yy <name of author>
- X
- X This program is free software; you can redistribute it and/or modify
- X it under the terms of the GNU General Public License as published by
- X the Free Software Foundation; either version 1, or (at your option)
- X any later version.
- X
- X This program is distributed in the hope that it will be useful,
- X but WITHOUT ANY WARRANTY; without even the implied warranty of
- X MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X GNU General Public License for more details.
- X
- X You should have received a copy of the GNU General Public License
- X along with this program; if not, write to the Free Software
- X Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- Also add information on how to contact you by electronic and paper mail.
- X
- If the program is interactive, make it output a short notice like this
- when it starts in an interactive mode:
- X
- X Gnomovision version 69, Copyright (C) 19xx name of author
- X Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- X This is free software, and you are welcome to redistribute it
- X under certain conditions; type `show c' for details.
- X
- The hypothetical commands `show w' and `show c' should show the
- appropriate parts of the General Public License. Of course, the
- commands you use may be called something other than `show w' and `show
- c'; they could even be mouse-clicks or menu items--whatever suits your
- program.
- X
- You should also get your employer (if you work as a programmer) or your
- school, if any, to sign a "copyright disclaimer" for the program, if
- necessary. Here a sample; alter the names:
- X
- X Yoyodyne, Inc., hereby disclaims all copyright interest in the
- X program `Gnomovision' (a program to direct compilers to make passes
- X at assemblers) written by James Hacker.
- X
- X <signature of Ty Coon>, 1 April 1989
- X Ty Coon, President of Vice
- X
- That's all there is to it!
- END_OF_FILE
- if test 12488 -ne `wc -c <'LICENCE'`; then
- echo shar: \"'LICENCE'\" unpacked with wrong size!
- fi
- # end of 'LICENCE'
- fi
- if test -f 'l.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'l.c'\"
- else
- echo shar: Extracting \"'l.c'\" \(15031 characters\)
- sed "s/^X//" >'l.c' <<'END_OF_FILE'
- X/*-------------------------------------------------------------------------
- X * Listserv - Unix Mailing List manager (sub-set of FRECP's
- X * Bitnet Listserv tool.
- X *
- X * Copyright (C) 1991,1992 Kimmo Suominen, Christophe Wolfhugel
- X *
- X * Please read the files COPYRIGHT and AUTHORS for the extended
- X * copyrights refering to this file.
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X *----------------------------------------------------------------------*/
- X
- static char rcsid[] = "@(#)$Id: l.c,v 1.34 93/03/02 22:13:17 wolf Exp $";
- X
- X#include <stdio.h>
- X#include <string.h>
- X#include <signal.h>
- X#include <time.h>
- X#include <unistd.h>
- X#include <ctype.h>
- X#include <sys/ioctl.h>
- X#include <sys/param.h>
- X#include <sys/times.h>
- X#include <sys/types.h>
- X#include <sys/stat.h>
- X#include "conf.h"
- X#include "ext.h"
- X#include "lp.h"
- X#include "str.h"
- X#include "popen.h"
- X#include "ad.h"
- X#include "lc.h"
- X#include "messages.h"
- X#ifdef FAKESYSLOG
- X# include "fakesyslog.h"
- X#else
- X# include <syslog.h>
- X#endif
- X
- int Debug = 0;
- X
- short subj;
- X
- int msgHere = 0, done = 0;
- char listName[64];
- char From[MAXLINE], To[MAXLINE], ReplyTo[MAXLINE];
- char buf[MAXLINE], rcpt[MAXLINE];
- int d, h, m, s;
- long startTime, endTime, msgSize;
- struct tms t;
- X
- static int ctr;
- X
- void lTodhms(t)
- long t;
- X{
- X d = t / ( 24 * 3600L );
- X h = ( t % ( 24 * 3600L )) / 3600;
- X m = ( t % 3600 ) /60;
- X s = t % 60;
- X}
- X
- char *instring(s1, s2)
- char *s1, *s2;
- X{
- X if ((int)strlen(s2) > (int)strlen(s1)) return(NULL);
- X for (; *(s1 + strlen(s2) - 1); s1++)
- X if (strncasecmp(s1, s2, strlen(s2)) == 0) return(s1);
- X return(NULL);
- X}
- X
- char *strlwr(s)
- char *s;
- X{
- X char *p = s;
- X
- X if (s==NULL) return(NULL);
- X for (; *s; s++) *s = tolower(*s);
- X return(p);
- X}
- X
- char *strupr(s)
- char *s;
- X{
- X char *p = s;
- X
- X if (s == NULL) return(NULL);
- X for (; *s; s++) *s = toupper(*s);
- X return(p);
- X}
- X
- void mailMsg(to, subj)
- char *to, *subj;
- X{
- X FILE *f, *g;
- X char buf[1024];
- X
- X sprintf(buf, "%s %s", SENDMAIL, to);
- X if ((g = l_popen(buf, "w")) == NULL) {
- X syslog(LOG_ERR, "mailMsg - popen failed: %m");
- X exit(2);
- X } /* endif */
- X if ((f = fopen("msg","r")) == NULL) {
- X syslog(LOG_ERR, "mailMsg - fopen failed: %m");
- X exit(2);
- X } /* endif */
- X fprintf(g, "Subject: %s\n\n", subj);
- X while (fgets(buf, sizeof(buf), f) != NULL)
- X fputs(buf, g);
- X l_pclose(g); fclose(f);
- X}
- X
- void sendMsg()
- X{
- X char cmd[MAXLINE + 256], *p;
- X int c;
- X FILE *f, *h;
- X
- X#ifdef ADD_REQUEST
- X sprintf(cmd, "%s -f%s-request %s", SENDMAIL, listName, rcpt);
- X#else
- X sprintf(cmd, "%s %s", SENDMAIL, rcpt);
- X#endif
- X if ((h = l_popen(cmd,"w")) == NULL) {
- X syslog(LOG_ERR, "sendMsg - popen: %m");
- X exit(2);
- X } /* endif */
- X if ((f = fopen("msg", "r")) == NULL) {
- X syslog(LOG_ERR, "sendMsg - popen: %m");
- X exit(2);
- X } /* endif */
- X while (fgets(buf, sizeof(buf), f) != NULL && buf[0] != '\n') {
- X /* if the line is too long, throw the rest away */
- X if (index(buf, '\n') == NULL) {
- X while ((c = getc(f)) != '\n' && c != EOF)
- X continue;
- X } /* endif */
- X while ((c = getc(f)) == ' ' || c == '\t') {
- X p = &buf[strlen(buf)];
- X *p++ = ' ';
- X if (fgets(p, sizeof(buf) - (p - buf), f) == NULL)
- X break;
- X } /* endwhile */
- X if (!feof(f) && !ferror(f))
- X ungetc(c, f);
- X
- X if (strncasecmp(buf, "Status: ", 8) == 0) continue;
- X if (strncasecmp(buf, "X-Envelope-To: ", 15) == 0) continue;
- X if (strncasecmp(buf, "X-Listserv-To: ", 15) == 0) continue;
- X if (strncasecmp(buf, ">From ", 6) == 0) continue;
- X if (strncasecmp(buf, "Return-receipt-to: ", 19) == 0) continue;
- X#ifdef STRIP_RECEIVED
- X if (strncasecmp(buf, "Received: ", 10) == 0) continue;
- X#endif
- X if (ReplyTo[0] != 0 && strncasecmp(buf, "Reply-To: ", 10) == 0)
- X continue;
- X if (*GetErrorsTo() != '\0' && strncasecmp(buf, "Errors-To: ", 11) == 0)
- X continue;
- X#ifdef ADD_SENDER
- X if (strncasecmp(buf, "Sender: ", 8) == 0) continue;
- X#endif
- X fputs(buf, h);
- X /* strcpy(cmd, listName); strupr(cmd);
- X fprintf(h, "To: %s Distribution List <%s@%s>\n", cmd, listName, HOST);
- X */
- X } /* endwhile */
- X#ifdef ADD_SENDER
- X fputs(versSender, h);
- X#endif
- X if (*GetErrorsTo() != '\0') fprintf(h, "Errors-To: %s\n", GetErrorsTo());
- X if (ReplyTo[0] != 0) fprintf(h, "Reply-To: %s\n", ReplyTo);
- X if (subj == 0) fprintf(h, "Subject: <none>\n");
- X if (ctr != 0) fprintf(h, "X-Sequence: %d\n", ctr);
- X do {
- X fputs(buf, h);
- X } while (fgets(buf, sizeof(buf), f) != NULL);
- X fclose(f); l_pclose(h);
- X}
- X
- void saveMsg()
- X{
- X FILE *f, *g;
- X long ti;
- X struct tm *t;
- X int dir = 0, oldfile = 0;
- X char cmd[64];
- X struct stat st;
- X
- X time(&ti); t = localtime(&ti); f = fopen("msg","r");
- X if (chdir(listName) == -1)
- X return;
- X else {
- X dir = 1;
- X sprintf(cmd, "log%02d%02d", t->tm_year, t->tm_mon + 1);
- X oldfile = stat(cmd, &st) + 1;
- X g = fopen(cmd, "a");
- X } /* endif */
- X if (!oldfile) {
- X fprintf(g, "This digest for list %s has been created on %s\n\n",
- X listName, asctime(t));
- X fputs("------- THIS IS A RFC934 COMPLIANT DIGEST, YOU CAN BURST IT -------\n\n", g);
- X }
- X while (fgets(buf, sizeof(buf), f) != NULL && buf[0] != '\n') {
- X if (strncmp(buf, "Subject:", 8) == 0 || strncmp(buf, "Date:", 5) == 0)
- X fputs(buf, g);
- X if (strncmp(buf, "From:", 5) == 0) {
- X fprintf(g, "From: %s\n", From);
- X if (subj == 0) fprintf(g, "Subject: <none>\n");
- X } /* endif */
- X strlwr(buf);
- X } /* endwhile */
- X if (ctr != 0) fprintf(g, "X-Sequence: %d\n", ctr);
- X do {
- X if (buf[0] == '-') { fprintf(g, "- "); }
- X fputs(buf, g);
- X } while (fgets(buf, 512, f) != NULL);
- X fputs("------- CUT --- CUT --- CUT --- CUT --- CUT --- CUT --- CUT -------\n\n", g);
- X fclose(f); fclose(g);
- X if (dir == 1) chdir(TULPDIR);
- X}
- X
- void fwdMsg()
- X{
- X FILE *f, *g, *h;
- X int i;
- X char *p;
- X char cmd[128];
- X
- X strcpy(listName, To);
- X if (ReadUserList(listName) == -1) {
- X syslog(LOG_INFO, "Sending error (list not found)");
- X mailMsg("list-errors", "List-Errors");
- X unlink("msg"); return;
- X } /* endif */
- X strcpy(buf, GetReplyTo());
- X if (ReplyTo[0] == 0 || instring(buf, ",respect") == NULL) {
- X if (strncasecmp(buf, "list", 4) == 0) {
- X strcpy(cmd, listName);
- X strupr(cmd);
- X sprintf(ReplyTo, "%s Distribution List <%s@%s>", cmd, listName, HOST);
- X } else if (strncasecmp(buf, "sender", 6) != 0)
- X sprintf(ReplyTo, "%s", strtok(buf, ","));
- X } /* endif */
- X RewindUserList();
- X if (strcasecmp(GetSend(), "private") == 0 && !IsUser(From)) {
- X syslog(LOG_INFO,
- X "Mail to list %s from %s - Refused, this user is not allowed",
- X listName, From);
- X sprintf(buf, "%s %s", SENDMAIL, strtok(From, " ")); /* NAK to sender */
- X if ((g = l_popen(buf, "w")) == NULL) {
- X syslog(LOG_ERR, "fwdMsg - popen failed: %m");
- X unlink("msg");
- X CloseUserList();
- X return;
- X } /* endif */
- X if ((f = fopen("msg", "r")) == NULL) {
- X syslog(LOG_ERR, "fwdMsg - fopen failed: %m");
- X unlink("msg");
- X CloseUserList();
- X return;
- X } /* endif */
- X fprintf(g, TULP_HDRMAILNAK(From, listName));
- X fprintf(g, TULP_MAILPRIVATE);
- X while (fgets(buf, sizeof(buf), f) != NULL) /* unsent message */
- X fputs(buf, g);
- X l_pclose(g); fclose(f);
- X mailMsg("list-errors", "attempt to send mail by a non subscriber");
- X /* to inform list-errors */
- X } else if (strcasecmp(GetSend(), "editor") == 0 && !IsEditor(From)) {
- X syslog(LOG_INFO,"Mail to list %s from %s - Article to moderate",
- X listName, From);
- X RewindEditorList();
- X if (GetEditor(buf) != NULL) {
- X mailMsg(strtok(buf, " "), "Article to moderate");
- X } /* endif */
- X } else { /* Ok to send */
- X strcpy(buf, listName); /* X-Sequence - update listName.n */
- X strcat(buf, ".n");
- X ctr = 0;
- X h = fopen(buf, "r+");
- X if (h != NULL) {
- X fscanf(h, "%d", &ctr);
- X rewind(h); fprintf(h, "%d\n", ++ctr); fclose(h);
- X } /* endif */
- X syslog(LOG_INFO,"List %s - Msg from %s accepted", listName, From);
- X saveMsg(); /* save Msg in log file */
- X i = 0; p = rcpt;
- X while (GetUser(buf) != NULL) {
- X strtok(buf, "\t\r\n ");
- X if (((p - rcpt) + strlen(buf)+2) < sizeof(rcpt) && i++ < BATCHSIZE) {
- X sprintf(p, "%s ", buf);
- X p += strlen(p);
- X } else {
- X i = 0; p = rcpt;
- X sendMsg();
- X } /* endif */
- X } /* endwhile */
- X if (i != 0) sendMsg();
- X } /* endif */
- X unlink("msg");
- X CloseUserList();
- X}
- X
- int copyMail()
- X{
- X FILE *h;
- X char *p;
- X int c;
- X struct stat st;
- X
- X if (access("msg", 0) == -1) {
- X winInc();
- X if ((h = popen(MAILX, "w")) == NULL) return(-1);
- X fprintf(h, "s 1 msg\n");
- X fprintf(h, "q\n");
- X pclose(h);
- X } /* endif */
- X if ((h = fopen("msg", "r")) == NULL) return(-1);
- X To[0] = 0;
- X fstat(fileno(h), &st); msgSize = st.st_size;
- X subj = 0; To[0] = ReplyTo[0] = 0;
- X while (fgets(buf, sizeof(buf), h) != NULL && buf[0] != '\n') {
- X /* if the line is too long, throw the rest away */
- X if (index(buf, '\n') == NULL) {
- X while ((c = getc(h)) != '\n' && c != EOF)
- X continue;
- X } /* endif */
- X while ((c = getc(h)) == ' ' || c == '\t') {
- X p = &buf[strlen(buf) - 1];
- X *p++ = ' ';
- X if (fgets(p, sizeof(buf) - (p - buf), h) == NULL)
- X break;
- X } /* endif */
- X if (!feof(h) && !ferror(h))
- X ungetc(c, h);
- X strtok(buf, "\n");
- X if (Debug) {
- X fprintf(stderr, "Collected line: %s\n", buf);
- X } /* endif */
- X if (strlen(buf) > MAXLINE) {
- X syslog(LOG_ERR, "Header line too long: %s", strtok(buf, ":"));
- X fclose(h);
- X return(-2);
- X } /* endif */
- X if (strncmp(buf, "Reply-To: ", 10) == 0) {
- X strcpy(ReplyTo, buf + 10);
- X } /* endif */
- X if (strncmp(buf, "Subject: ", 9) == 0) {
- X /* We could save subject here, but we don't need it */
- X subj = 1;
- X continue;
- X } /* endif */
- X if (strncmp(buf, "From: ", 6) == 0) {
- X /* Usually just one author */
- X strcpy(From, buf + 6);
- X continue;
- X } /* endif */
- X if (strncmp(buf, "X-Listserv-To: ", 15) == 0 ) {
- X strcpy(To, buf + 15);
- X continue;
- X } /* endif */
- X } /* endwhile */
- X adChange(From);
- X strlwr(To);
- X fclose(h);
- X if (To[0] == 0) {
- X syslog(LOG_ERR, "Empry X-Listserv-To or not found");
- X return(-2);
- X } /* endif */
- X}
- X
- void sTe()
- X{
- X done = 1;
- X}
- X
- X#ifndef NO_SIGUSR1
- void sPau()
- X{
- X msgHere = 1;
- X}
- X#endif
- X
- void main(int argn, char **argv)
- X{
- X struct stat st;
- X struct sigaction sa;
- X FILE *f;
- X int i;
- X extern void reapchild();
- X
- X while ((i = getopt(argn, argv, "d")) != EOF) {
- X switch (i) {
- X case 'd':
- X Debug = 1;
- X break;
- X default:
- X fprintf(stderr,"usage: %s [-d]\n", *argv);
- X exit(1);
- X } /* endsw */
- X } /* endif */
- X versInit();
- X if (chdir(TULPDIR) == -1) {
- X perror("Can't chdir' to TULPDIR. Aborting.");
- X exit(2);
- X } /* endif */
- X setbuf(stdout, NULL); printf("%s: daemon started for %s\n\r", vers, HOST);
- X printf("Copyright (C) 1991,1992 Kimmo Suominen, Christophe Wolfhugel\n");
- X printf("Listserv comes with ABSOLUTELY NO WARRANTY; for details see\n");
- X printf("the GNU General Public License that is furnished with the\n");
- X printf("sources of this package.\n");
- X if (Debug == 0)
- X if (fork()) exit (0); /* Dissociate us from tty */
- X times(&t);
- X time(&startTime);
- X nice(NICENESS);
- X if (Debug == 0) {
- X freopen("/dev/null", "w", stdout);
- X freopen("/dev/null", "w", stderr);
- X close(fileno(stdin));
- X setpgrp();
- X } /* endif */
- X sigemptyset(&sa.sa_mask);
- X#ifdef SA_RESTART
- X sa.sa_flags = SA_RESTART; /* Restart system calls? SA_RESTART */
- X /* Children? SA_NOCLDWAIT, SA_NOCLDSTOP */
- X#else
- X sa.sa_flags = 0;
- X#endif
- X sa.sa_handler = sTe;
- X sigaction(SIGTERM, &sa, NULL);
- X#ifdef SIGURGENT
- X sigaction(SIGURGENT, &sa, NULL);
- X#endif
- X sa.sa_handler = SIG_IGN;
- X /* sa.sa_flags = SA_RESETHAND; /* Reset to SIG_DFL, not blocked */
- X#ifndef NO_SIGUSR1
- X sigaction(SIGUSR1, &sa, NULL);
- X#endif
- X sa.sa_handler = reapchild;
- X sigaction(SIGCHLD, &sa, NULL);
- X umask(022);
- X openlog("listserv", LOG_PID, LOG_AUTH);
- X syslog(LOG_INFO, "Listserv Started");
- X f = fopen(PIDFILE, "w");
- X if (f == NULL) {
- X syslog(LOG_ERR, "Can't open PIDFILE for writing. Aborting.");
- X exit(2);
- X } /* endif */
- X fprintf(f, "%d", getpid());
- X fclose(f);
- X umask(077);
- X while (!done) {
- X if (access("msg", 0) == -1 && (stat(MAILFILE, &st) == -1
- X || st.st_size == 0)) {
- X#ifdef NO_SIGUSR1
- X sleep(NO_SIGUSR1);
- X#else
- X if (msgHere == 0) {
- X sa.sa_handler = sPau;
- X sigaction(SIGUSR1,&sa,NULL);
- X pause();
- X sa.sa_handler=SIG_IGN;
- X sigaction(SIGUSR1,&sa,NULL);
- X }
- X#endif
- X continue;
- X } /* endif */
- X msgHere = 0;
- X if ((i = copyMail()) == -1) continue;
- X if (i == -2) {
- X mailMsg("list-errors", "Unknown error in saveMsg(), see the syslog");
- X unlink("msg");
- X continue;
- X } /* endif */
- X if (instring(From, "mailer") != NULL ||
- X instring(From, "postmaster") != NULL ||
- X instring(From, "listserv") != NULL ||
- X instring(From, "root") != NULL ||
- X instring(From, "system") != NULL ||
- X instring(From, "-request") != NULL ||
- X instring(From, "owner-") != NULL) {
- X syslog(LOG_INFO,"Message from Mailer-Daemon");
- X mailMsg("list-errors", "Trouble");
- X unlink("msg");
- X continue;
- X } /* endif */
- X if (strcmp(To, "listserv") == 0)
- X { listservCmd(); } else { fwdMsg(); }
- X } /* endwhile */
- X syslog(LOG_INFO,"Listserv has been terminated");
- X time(&endTime); lTodhms(endTime-startTime);
- X times(&t);
- X t.tms_utime+=t.tms_cutime;
- X t.tms_stime+=t.tms_cstime;
- X syslog(LOG_INFO,"Total elapsed time: +%dd %02d:%02d:%02d\n",d,h,m,s);
- X lTodhms(t.tms_utime/HZ);
- X syslog(LOG_INFO,"User CPU time: +%dd %02d:%02d:%02d\n",d,h,m,s);
- X lTodhms(t.tms_stime/HZ);
- X syslog(LOG_INFO,"System CPU time: +%dd %02d:%02d:%02d\n",d,h,m,s);
- X lTodhms((t.tms_utime+=t.tms_stime)/HZ);
- X syslog(LOG_INFO,"Total CPU time: +%dd %02d:%02d:%02d\n",d,h,m,s);
- X syslog(LOG_INFO,"%% CPU used: %02.02f%%\n",
- X (float)(t.tms_utime/HZ*100)/(float)(endTime-startTime+1));
- X closelog();
- X unlink(PIDFILE);
- X exit(0);
- X}
- END_OF_FILE
- if test 15031 -ne `wc -c <'l.c'`; then
- echo shar: \"'l.c'\" unpacked with wrong size!
- fi
- # end of 'l.c'
- fi
- if test -f 'lc.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'lc.c'\"
- else
- echo shar: Extracting \"'lc.c'\" \(12273 characters\)
- sed "s/^X//" >'lc.c' <<'END_OF_FILE'
- X/*-------------------------------------------------------------------------
- X * Listserv - Unix Mailing List manager (sub-set of FRECP's
- X * Bitnet Listserv tool.
- X *
- X * Copyright (C) 1991,1992 Kimmo Suominen, Christophe Wolfhugel
- X *
- X * Please read the files COPYRIGHT and AUTHORS for the extended
- X * copyrights refering to this file.
- X *
- X * This program is free software; you can redistribute it and/or modify
- X * it under the terms of the GNU General Public License as published by
- X * the Free Software Foundation; either version 1, or (at your option)
- X * any later version.
- X *
- X * This program is distributed in the hope that it will be useful,
- X * but WITHOUT ANY WARRANTY; without even the implied warranty of
- X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- X * GNU General Public License for more details.
- X *
- X * You should have received a copy of the GNU General Public License
- X * along with this program; if not, write to the Free Software
- X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X *----------------------------------------------------------------------*/
- X
- static char rcsid[] = "@(#)$Id: lc.c,v 1.22 93/03/02 22:40:31 wolf Exp $";
- X
- X#include <stdio.h>
- X#include <string.h>
- X#include <unistd.h>
- X#include <limits.h>
- X#include <sys/param.h>
- X#include <sys/types.h>
- X#include <signal.h>
- X#include <sys/stat.h>
- X#include <dirent.h>
- X#include <sys/times.h>
- X#include "conf.h"
- X#include "ext.h"
- X#include "l.h"
- X#include "lp.h"
- X#include "str.h"
- X#include "popen.h"
- X#include "messages.h"
- X#ifdef FAKESYSLOG
- X# include "fakesyslog.h"
- X#else
- X# include <syslog.h>
- X#endif
- X
- XFILE *l;
- char adrs[MAXLINE];
- static char cmd[MAXLINE + 1];
- X
- struct kword {
- X char k[4];
- X void (*job)();
- X};
- X
- void help(), list(), review(), subscribe(), signoff(), listindex(),
- X getFile(), addUser(), delUser();
- X
- struct kword kw[] = { "hel", help,
- X "lis", list,
- X "rev", review,
- X "sub", subscribe,
- X "sig", signoff,
- X "uns", signoff,
- X "ind", listindex,
- X "get", getFile,
- X "add", addUser,
- X "del", delUser,
- X "", NULL };
- X
- X/*
- X * Spawn return message MTA
- X */
- X
- XFILE *getMTA(char *recipient)
- X{
- X FILE *mta;
- X
- X#ifdef ADD_REQUEST
- X sprintf(cmd,"%s -flistserv-request %s",SENDMAIL,recipient);
- X#else
- X sprintf(cmd,"%s %s",SENDMAIL,recipient);
- X#endif
- X mta = l_popen(cmd,"w");
- X fprintf(mta, versFrom);
- X#ifdef ADD_SENDER
- X fprintf(mta, versSender);
- X#endif
- X return(mta);
- X}
- X
- X/*
- X * HELP
- X */
- X
- void help()
- X{
- X FILE *f,*h;
- X
- X strlwr(buf);
- X syslog(LOG_INFO,"HELP to %s",From);
- X h=getMTA(adrs);
- X fprintf(h,TULP_HDRHELP(From));
- X f=fopen("helpfile","r");
- X while (fgets(buf, sizeof(buf), f) != NULL)
- X fputs(buf,h);
- X fclose(f);
- X l_pclose(h);
- X}
- X
- X
- X/*
- X * LIST
- X */
- X
- void list()
- X{
- X FILE *f,*h;
- X
- X syslog(LOG_INFO,"LIST to %s",From);
- X h=getMTA(adrs);
- X fprintf(h,TULP_HDRLIST(From));
- X f=fopen("lists","r");
- X while (fgets(buf, sizeof(buf) ,f) != NULL) {
- X if (buf[0] == '#') continue;
- X strtok(buf,",");
- X fprintf(h,"%-15s * %s\n",buf,strtok(NULL,"\n"));
- X } /* endwhile */
- X fclose(f);
- X l_pclose(h);
- X}
- X
- X
- X/*
- X * REVIEW list
- X */
- X
- void review()
- X{
- X FILE *h;
- X char *s;
- X
- X s=strtok(NULL," \t\n"); strlwr(s);
- X syslog(LOG_INFO,"REV '%s' to %s",s,From);
- X if (s == NULL)
- X fprintf(l,TULP_SYNTAX);
- X else
- X if (ReadUserList(s) == -1)
- X fprintf(l,TULP_NOSUCHLIST);
- X else {
- X h=getMTA(adrs);
- X fprintf(h,TULP_HDRREV(From,s));
- X RewindCommentList();
- X RewindUserList();
- X while (GetComment(buf) != NULL)
- X fprintf(h,"%s\n",buf);
- X if (!IsOwner(From) && (strcasecmp(GetReview(), "owner") == 0
- X || (strcasecmp(GetReview(),"private") == 0 && !IsUser(From))))
- X fprintf(l,TULP_REVPRIVATE);
- X else
- X while (GetUser(buf) != NULL) {
- X strtok(buf,"(");
- X buf[strlen(buf)-1]=0;
- X fprintf(h,"%-40s %s\n",buf,strtok(NULL,")\n"));
- X } /* endwhile */
- X l_pclose(h);
- X } /* endif */
- X CloseUserList();
- X}
- X
- X
- X/*
- X * SUBSCRIBE list first last
- X */
- X
- void subscribe()
- X{
- X FILE *f,*h;
- X char *s1,*s2;
- X
- X s1=strtok(NULL," \n");
- X strlwr(s1);
- X s2=strtok(NULL,"\n");
- X syslog(LOG_INFO,"SUB '%s' from %s",s1,From);
- X if (s1 == NULL || s2 == NULL)
- X fprintf(l,TULP_SYNTAX);
- X else {
- X if (ReadUserList(s1) == -1)
- X fprintf(l,TULP_NOSUCHLIST);
- X else {
- X RewindUserList();
- X RewindOwnerList();
- X if (strcasecmp(GetSubscription(),"closed") == 0)
- X fprintf(l,TULP_SUBCLOSED);
- X else
- X if (strcasecmp(GetSubscription(),"owner") == 0) {
- X fprintf(l,TULP_SUBFORWARDED);
- X rcpt[0]=0;
- X while (GetOwner(cmd) != NULL) {
- X strcat(rcpt,strtok(cmd," \t\r\n"));
- X strcat(rcpt," ");
- X } /* endwhile */
- X sprintf(cmd,"%s %s",SENDMAIL,rcpt);
- X f=l_popen(cmd,"w");
- X fprintf(f,TULP_SUBREQUEST(adrs,s1,s2));
- X l_pclose(f);
- X } else {
- X sprintf(cmd,"%s (%s)",adrs,s2);
- X switch (AddUser(cmd)) {
- X case 0:
- X h=getMTA(adrs);
- X fprintf(h,TULP_HDRWELCOME(From,s1));
- X strcat(s1,".w");
- X f=fopen(s1,"r");
- X while (fgets(buf, sizeof(buf), f) != NULL)
- X fputs(buf,h);
- X fclose(f);
- X l_pclose(h);
- X break;
- X case 1:
- X fprintf(l,TULP_SUBALREADY);
- X break;
- X } /* endsw */
- X WriteUserList();
- X } /* endif */
- X } /* endif */
- X CloseUserList();
- X } /* endif */
- X}
- X
- X
- X/*
- X * SIGNOFF list
- X */
- X
- void signoff()
- X{
- X FILE *f;
- X char *s;
- X
- X s=strtok(NULL," \t\n");
- X strlwr(s);
- X syslog(LOG_INFO,"SIG '%s' from %s",s,From);
- X if (s == NULL)
- X fprintf(l,TULP_SYNTAX);
- X else
- X if (ReadUserList(s) == -1)
- X fprintf(l,TULP_NOSUCHLIST);
- X else {
- X RewindOwnerList();
- X rcpt[0]=0;
- X while (GetOwner(cmd) != NULL) {
- X strcat(rcpt,strtok(cmd," "));
- X strcat(rcpt," ");
- X } /* endwhile */
- X sprintf(cmd,"%s %s",SENDMAIL,rcpt);
- X f=l_popen(cmd,"w");
- X if (DelUser(adrs) == -1) {
- X fprintf(f,TULP_SIGFAILED(adrs,s));
- X fprintf(l,TULP_NOTONLIST);
- X } else {
- X fprintf(f,TULP_SIGSUCCESS(adrs,s));
- X fprintf(l,TULP_SIGDONE);
- X }
- X l_pclose(f);
- X WriteUserList();
- X CloseUserList();
- X } /* endif */
- X}
- X
- X/*
- X * INDEX list
- X */
- X
- void listindex()
- X{
- X#define MAX_FILES 640
- X static char files[MAX_FILES][64+1], swp[64+1];
- X FILE *h;
- X char *s;
- X int i,j,noFiles;
- X DIR *dirp;
- X struct dirent *de;
- X struct stat st;
- X
- X s=strtok(NULL,"\n");
- X strlwr(s);
- X syslog(LOG_INFO,"IND %s from %s",s,From);
- X if (s == NULL || s[0] == '/' || s[0] == '~' || strstr(s,"..") != NULL)
- X fprintf(l,TULP_SYNTAX);
- X else {
- X if (ReadUserList(s) != -1 && (strcasecmp(GetSend(),"public") != 0
- X || strcasecmp(GetReview(), "public") != 0)
- X && !IsUser(From) && !IsOwner(From))
- X fprintf(l,TULP_NOTONLIST);
- X else {
- X if (chdir(s) == -1) fprintf(l,TULP_NONESTORED);
- X else {
- X h=getMTA(adrs);
- X fprintf(h,TULP_HDRINDEX(From,s));
- X dirp=opendir(".");
- X noFiles=0;
- X while (noFiles < MAX_FILES && (de=readdir(dirp)) != NULL)
- X if (de->d_name[0] != '.')
- X strcpy(files[noFiles++],de->d_name);
- X closedir(dirp);
- X for (i=0; i < noFiles-1; i++) {
- X for (j=i+1; j < noFiles; j++) {
- X if (strcmp(files[j],files[i]) < 0) {
- X strcpy(swp,files[i]);
- X strcpy(files[i],files[j]);
- X strcpy(files[j],swp);
- X } /* endif */
- X } /* endfor */
- X } /* endfor */
- X for (i=0; i < noFiles; i++) {
- X stat(files[i],&st);
- X if (st.st_mode & S_IFDIR) strcat(files[i],"/");
- X fprintf(h,"%-40s %10ld %s",files[i],st.st_size,ctime(&st.st_mtime));
- X } /* endif */
- X chdir(TULPDIR);
- X if (noFiles == 0) fprintf(l,TULP_INDNOFILES);
- X l_pclose(h);
- X } /* endif */
- X } /* endif */
- X CloseUserList();
- X } /* endif */
- X}
- X
- X/*
- X * GET list file
- X */
- X
- void getFile()
- X{
- X FILE *f,*h;
- X char *s,*t;
- X
- X s=strtok(NULL," ");
- X t=strtok(NULL," \n");
- X strlwr(s);
- X strlwr(t);
- X syslog(LOG_INFO,"GET %s %s from %s",
- X (s == NULL) ? " " : s, (t == NULL) ? " " : t, From);
- X if (ReadUserList(s) != -1 && (strcasecmp(GetSend(),"public") != 0
- X || strcasecmp(GetReview(), "public") != 0)
- X && !IsUser(From) && !IsOwner(From))
- X fprintf(l,TULP_NOTONLIST);
- X else {
- X if (chdir(s) == -1) fprintf(l,TULP_NONESTORED);
- X else {
- X if (strstr(t,"..") != NULL || *t == '/' || *t == '~') *t=0;
- X f=fopen(t,"r");
- X if (f == NULL) fprintf(l,TULP_GETNOSUCHFILE);
- X else {
- X h=getMTA(adrs);
- X fprintf(h,TULP_HDRGET(From,s,t));
- X while (fgets(buf, sizeof(buf), f) != NULL)
- X fputs(buf,h);
- X fclose(f);
- X l_pclose(h);
- X } /* endif */
- X chdir(TULPDIR);
- X } /* endif */
- X } /* endif */
- X CloseUserList();
- X}
- X
- X/*
- X * ADD list user@host.foo.bar First Last
- X */
- X
- void addUser()
- X{
- X FILE *f,*h;
- X char *s,*t,*u;
- X
- X s=strtok(NULL," \n");
- X t=strtok(NULL," \n");
- X u=strtok(NULL,"\n");
- X strlwr(s);
- X syslog(LOG_INFO,"ADD '%s' %s from %s",s,t,From);
- X if (s == NULL || t == NULL || u == NULL)
- X fprintf(l,TULP_SYNTAX);
- X else
- X if (ReadUserList(s) == -1)
- X fprintf(l,TULP_NOSUCHLIST);
- X else {
- X RewindUserList();
- X RewindOwnerList();
- X if (!IsOwner(From))
- X fprintf(l,TULP_NOTOWNER);
- X else {
- X h=getMTA(t);
- X sprintf(cmd,"%s (%s)",t,u);
- X switch (AddUser(cmd)) {
- X case 0:
- X fprintf(h,TULP_HDRWELCOME(cmd,s));
- X fprintf(h,TULP_ADDBY(cmd,s,From));
- X strcat(s,".w");
- X f=fopen(s,"r");
- X while (fgets(buf, sizeof(buf),f) != NULL)
- X fputs(buf,h);
- X fclose(f);
- X fprintf(l,TULP_ADDSUCCESS);
- X break;
- X case 1:
- X fprintf(h,TULP_SUBUPDATED(cmd,s,From));
- X fprintf(l,TULP_ADDALREADY);
- X break;
- X } /* endsw */
- X l_pclose(h);
- X } /* endif */
- X WriteUserList();
- X CloseUserList();
- X }
- X}
- X
- X/*
- X * DELETE list user@host.foo.bar
- X */
- X
- void delUser()
- X{
- X FILE *h;
- X char *s1,*s2;
- X
- X s1=strtok(NULL," \n");
- X s2=strtok(NULL," \n");
- X strlwr(s1);
- X syslog(LOG_INFO,"DEL '%s' %s from %s",s1,s2,From);
- X if (s1 == NULL || s2 == NULL)
- X fprintf(l,TULP_SYNTAX);
- X else
- X if (ReadUserList(s1) == -1)
- X fprintf(l,TULP_NOSUCHLIST);
- X else {
- X RewindUserList();
- X RewindOwnerList();
- X if (!IsOwner(From))
- X fprintf(l,TULP_NOTOWNER);
- X else
- X if (!IsUser(s2))
- X fprintf(l,TULP_DELNOTONLIST);
- X else {
- X sprintf(cmd,"%s",s2);
- X switch (DelUser(cmd)) {
- X case 0:
- X h=getMTA(s2);
- X fprintf(h,TULP_DELREMOVED(s2,s1,From));
- X l_pclose(h);
- X fprintf(l,TULP_DELSUCCESS);
- X break;
- X case -1:
- X fprintf(l,TULP_DELINCONSISTENT);
- X break;
- X } /* endsw */
- X } /* endif */
- X WriteUserList();
- X CloseUserList();
- X } /* endif */
- X}
- X
- X
- int doCmd()
- X{
- X int i;
- X char s[4];
- X
- X if (buf[0] == '\n') return(0);
- X strncpy(s,strtok(buf," "),3);
- X s[3]='\0';
- X strlwr(s);
- X for (i=0; kw[i].k[0] != 0; i++)
- X if (strncmp(kw[i].k,s,3) == 0) {
- X kw[i].job();
- X return(0);
- X }
- X return(-1);
- X}
- X
- void listservCmd()
- X{
- X int done, noCmd;
- X char cmd[256];
- X FILE *f;
- X#ifdef CPUTYPE
- X struct tms t;
- X long tt;
- X
- X times(&t); tt=t.tms_stime+t.tms_utime+t.tms_cstime+t.tms_cutime;
- X#endif
- X
- X noCmd = 0;
- X done = 0;
- X strcpy(adrs, From); strtok(adrs, " ");
- X l = getMTA(adrs);
- X fprintf(l, TULP_HDROUTPUT(From));
- X f = fopen("msg", "r");
- X buf[0] = 0;
- X while (fgets(buf, sizeof(buf), f) != NULL && buf[0] != '\n')
- X buf[0]=0;
- X if (buf[0] == 0)
- X fprintf(l, TULP_NOBODY);
- X else {
- X while (!done && fgets(buf, sizeof(buf) - 3, f) != NULL) {
- X if (strncasecmp(buf, "quit", 4) == 0
- X || strncasecmp(buf, "end", 3) == 0
- X || strncasecmp(buf, "stop", 4) == 0
- X || buf[0] == '-') {
- X fprintf(l, "> %s",buf);
- X fprintf(l, TULP_EXITING);
- X break;
- X } /* endif */
- X#ifdef SHUTDOWN
- X if (strcmp(SHUTDOWN, buf) == 0) {
- X syslog(LOG_INFO, "Shutdown by %s", From);
- X done = 1; /* this is clean */
- X noCmd++;
- X continue;
- X } /* endif */
- X#endif
- X if (buf[0] != '\n') {
- X fprintf(l,"> %s",buf);
- X if (doCmd() == -1)
- X fprintf(l,TULP_SAYWHAT);
- X else {
- X noCmd++;
- X fprintf(l,TULP_OKAY);
- X } /* endif */
- X } /* endif */
- X } /* endwhile */
- X } /* endif */
- X if (noCmd == 0) {
- X fprintf(l,TULP_NOCOMMANDS);
- X syslog(LOG_INFO,"no commands from",From);
- X mailMsg("listman","No commands");
- X } /* endif */
- X fclose(f);
- X unlink("msg");
- X#ifdef CPUTYPE
- X times(&t);
- X tt=(t.tms_stime+t.tms_utime+t.tms_cstime+t.tms_cutime)-tt;
- X fprintf(l,TULP_TOTAL((float)tt/HZ,CPUTYPE));
- X#endif
- X l_pclose(l);
- X}
- END_OF_FILE
- if test 12273 -ne `wc -c <'lc.c'`; then
- echo shar: \"'lc.c'\" unpacked with wrong size!
- fi
- # end of 'lc.c'
- fi
- echo shar: End of archive 2 \(of 2\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked both archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-